1857A - Array Coloring - CodeForces Solution


greedy math

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define read(x) ll x; cin >> x
#define endll '\n'
#define print(x) cout << x << endll
#define py cout << "YES\n"
#define pn cout << "NO\n"
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define frr(i, a, b) for (ll i = b; i >= a; i--)
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define vecp(v) for (auto i : v) cout << i << ' '; cout << endll
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef set<ll> stll;
typedef map<ll, ll> mpll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main(){
    int t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vll v(n);
        ll odd=0;
        fr(i,0,n){
            cin>>v[i];
            if(v[i]%2!=0){
                odd++;
            }
            

        }
         if(odd %2==0 ){
               py<<endl;
              
        }
        else{
            pn<<endl;
        }

    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1288A - Deadline
1617A - Forbidden Subsequence
914A - Perfect Squares
873D - Merge Sort
1251A - Broken Keyboard
463B - Caisa and Pylons
584A - Olesya and Rodion
799A - Carrot Cakes
1569B - Chess Tournament
1047B - Cover Points
1381B - Unmerge
1256A - Payment Without Change
908B - New Year and Buggy Bot
979A - Pizza Pizza Pizza
731A - Night at the Museum
742A - Arpa’s hard exam and Mehrdad’s naive cheat
1492A - Three swimmers
1360E - Polygon
1517D - Explorer Space
1230B - Ania and Minimizing
1201A - Important Exam
676A - Nicholas and Permutation
431A - Black Square
474B - Worms
987B - High School Become Human
1223A - CME
1658B - Marin and Anti-coprime Permutation
14B - Young Photographer
143A - Help Vasilisa the Wise 2
320A - Magic Numbers